<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949.46">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #5e672a; min-height: 16.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #672f30}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #1131a7}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #5f3233}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #1633a2}
p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #5e672a}
p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica}
p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px}
p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #4f3536}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #1131a7}
span.s3 {color: #5b6825}
span.s4 {color: #000000}
span.s5 {color: #1633a2}
span.s6 {color: #5e672a}
span.s7 {color: #1e3a9d}
span.s8 {color: #65642f}
span.s9 {color: #4f3536}
span.s10 {color: #606060}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>ProcModR<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b></span><b>A extension to the ProcMod real-time control structure!</b></p>
<p class="p2"><br></p>
<p class="p3"><b>ProcModR - A structure for controlling modular processes, with the capabilitiy to record its output</b></p>
<p class="p3"><b><span class="Apple-tab-span">	</span>in real-time</b></p>
<p class="p2"><br></p>
<p class="p3"><b>Class Methods</b></p>
<p class="p2"><br></p>
<p class="p3"><b>*new(env, amp, numChannels, procout, id, group, addAction, target, function, releaseFunc,<span class="Apple-converted-space"> </span></b></p>
<p class="p3"><b><span class="Apple-tab-span">	</span>onReleaseFunc, responder,</b> <b>timeScale, lag, clock, server)</b></p>
<p class="p2"><br></p>
<p class="p3"><span class="Apple-tab-span">	</span><b>env - </b>an overall amplitude envelope that synths created and sent to the ProcModRs internal routing bus <span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>will be shaped by. There is a max of 20 breakpoints to the env. If the Env has a releaseNode,</p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>ProcModR will continue to process events until .release is called.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>amp - </b>an overall amplitude control for an instance of ProcMod.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>numChannels -</b> the number of channels of output events in this function will contain.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>procout -</b> where the sound from this ProcModR should be routed to.<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span><b>id - </b>a \symbol or "string" to be used later to identify an instance of ProcMod.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>group - </b>a group for an instance of ProcMod to run in. Defaults to nil and a new group is created. If<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>ProcMod creates the group, a new one is created on each .play call.</p>
<p class="p3"><b><span class="Apple-tab-span">	</span>addAction - </b>an addAction for this instance of ProcMod. Defaults to 0.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>target -</b> a target for this instance of ProcMod. Defaults to 1.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>function</b> - a Function, Task or Routine to be evaluated on the playing of this instance of ProcMod.</p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>If a Function is passed in that returns a Task or Routine, the ProcMod will become 're-triggerable'</p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>and will allow for overlapping getures (it can be released and restarted immediately). All Functions,</p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>when evaluated, will have the current group id and envbus passed in as an argument.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>releaseFunc</b> - a Function, Task or Routine to be evaluated after the ProcMod has finished its release</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>onReleaseFunc</b> - a Function, Task or Routine to be evaluated at release time.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>responder</b> -<span class="Apple-converted-space">  </span>an instance of OSCresponder or OSCresponderNode for use by this instance<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>of ProcMod. It is automatically added when the ProcMod starts, and released after the ProcMod</p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>finishes its release.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>timeScale -</b> applies a scale function to the ProcMod envelope. Defaults to 1.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>lag -</b> applies to chages to the amp value passed into this instance of ProcMod.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>clock -</b> an intance of Clock to run this instance of ProcMod. Defaults to SystemClock.</p>
<p class="p3"><span class="Apple-tab-span">	</span><b>server -</b> an instance of Server to run this ProcMod on. Useful for remote servers.<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Defaults to Server.default.</p>
<p class="p2"><br></p>
<p class="p3"><b>Instance methods</b></p>
<p class="p2"><br></p>
<p class="p3"><b>play - </b>evaluates this instance of ProcMod. ProcMod.function is evaluated,<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>and ProcMod.responder is set up if they are declared.<span class="Apple-converted-space"> </span></p>
<p class="p2"><span class="Apple-tab-span">	</span></p>
<p class="p3"><b>value - </b>same as .play.</p>
<p class="p2"><br></p>
<p class="p3"><b>release - </b>releases an instance of ProcMod. If ProcMod.env has a release section, functions and</p>
<p class="p3"><span class="Apple-tab-span">	</span>OSCresponders wait until this has executed before releasing the ProcMods functionality.</p>
<p class="p2"><span class="Apple-tab-span">	</span></p>
<p class="p3"><b>kill - </b>immediately free the ProcMod, regardless of ProcMod.env.</p>
<p class="p2"><br></p>
<p class="p3"><b>group -</b> return the current group of this instance of ProcMod.</p>
<p class="p2"><br></p>
<p class="p3"><b>envbus - </b>return the current control bus id the global envelope is written to for this instance of ProcMod.</p>
<p class="p2"><span class="Apple-tab-span">	</span></p>
<p class="p3"><b>env_( Env or Number) -</b> an instance of Env to be sent to the synthdef controlling an instance of ProcMods<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>overall amplitude and event control. If a Number is passed in, it will represent a releasetime for the<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>ProcMod.</p>
<p class="p2"><span class="Apple-tab-span">	</span></p>
<p class="p3"><b>function_( func ) </b>- an instance of Function, Task or Routine to be evaluated on ProcMod.play. If a Function is<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>passed in, the ProcMod will become 're-triggerable' and can be restarted after it has been released. If</p>
<p class="p3"><span class="Apple-tab-span">	</span>a Function is passed in, it may return a Task or Routine. The function is passed the ProcMod's current</p>
<p class="p3"><span class="Apple-tab-span">	</span>group and envbus as args.</p>
<p class="p2"><br></p>
<p class="p3"><b>releaseFunc_( func )<span class="Apple-converted-space"> </span></b> - an instance of Function, Task or Routine to be evaluated after a ProcMod has released.</p>
<p class="p2"><br></p>
<p class="p3"><b>onReleaseFunc_( func )<span class="Apple-converted-space"> </span></b> - an instance of Function, Task or Routine to be evaluated the moment a ProcMod is</p>
<p class="p3"><span class="Apple-converted-space"> <span class="Apple-tab-span">	</span></span>released.</p>
<p class="p2"><br></p>
<p class="p3"><b>responder_( OSCresponder) </b>- an instance of OSCresponder or OSCresponderNode for use by an instance<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>of ProcMod.</p>
<p class="p2"><br></p>
<p class="p3"><b>amp_( val ) -<span class="Apple-converted-space"> </span></b> If there is an envelope controlling the overall amplitude of events, set the amplitude to val.</p>
<p class="p2"><br></p>
<p class="p3"><b>lag_( val ) -<span class="Apple-converted-space"> </span></b> If there is an envelope controlling the overall amplitude of events, set the lag time for changes of<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>amplitude to take effect (with the amp_ instance method)</p>
<p class="p2"><span class="Apple-tab-span">	</span></p>
<p class="p3"><b>saveToData( Association ) -<span class="Apple-converted-space"> </span><i> </i></b>places the Association into a Dictionary for later access. Any Association may be<span class="Apple-converted-space"> </span></p>
<p class="p3"><span class="Apple-tab-span">	</span>stored.<span class="Apple-converted-space"> </span></p>
<p class="p2"><br></p>
<p class="p3"><b>Examples:</b></p>
<p class="p4"><br></p>
<p class="p5"><span class="s2">SynthDef</span>(<span class="s3">\singrain</span>, {<span class="s2">arg</span> outbus, freq, amp, dur;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">OffsetOut</span>.ar(outbus,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">Pan2</span>.ar(</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">SinOsc</span>.ar(freq, 0, amp) *<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>.sine(dur, amp), doneAction: 2),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">Rand</span>.new(-1.0, 1.0)</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span>) </span>// read off the overall env control of the ProcMod</p>
<p class="p5">}).load(s);</p>
<p class="p7"><span class="Apple-tab-span">	</span></p>
<p class="p6">// create a new ProcModR, and assign a function to it</p>
<p class="p5">a = <span class="s2">ProcModR</span>.new(<span class="s2">Env</span>([0, 1, 0], [1, 1], <span class="s3">\sin</span>, 1), 1, 2, 0, server: s);</p>
<p class="p5">a.function_({<span class="s2">arg</span> group, routebus, server;</p>
<p class="p8"><span class="s4"><span class="Apple-tab-span">	</span></span>Task<span class="s4">({</span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">inf</span>.do({</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// start a new synth... run it inside this ProcMod's group,</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// and read control values off the envbus</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>server.sendMsg(<span class="s3">\s_new</span>, <span class="s3">\singrain</span>, server.nextNodeID, 0, group,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">\freq</span>, 440.rrand(1760), <span class="s3">\amp</span>, 0.1, <span class="s3">\dur</span>, 5, <span class="s3">\outbus, routebus</span>);</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>0.5.wait;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>})</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span>});</p>
<p class="p7"><br></p>
<p class="p6">// play it</p>
<p class="p5">a.play;</p>
<p class="p6">// change the amp</p>
<p class="p5">a.amp_(2);</p>
<p class="p6">// change the lag</p>
<p class="p5">a.lag_(0.5);</p>
<p class="p6">// change the amp again</p>
<p class="p5">a.amp_(5);</p>
<p class="p6">// release it</p>
<p class="p5">a.release;</p>
<p class="p7"><br></p>
<p class="p6">// creating ProcMods in a functional way</p>
<p class="p7"><br></p>
<p class="p5">a = {<span class="s2">arg</span> amp, env, high, low, winsize, overlaps;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> proc;</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span></span>// defaults to Server.default if no Server is supplied</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc = <span class="s2">ProcModR</span>.new(env, amp, 2, 0);</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc.function_({<span class="s2">arg</span> group, routebus, server;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">Task</span>({</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">inf</span>.do({</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// start a new synth... run it inside this ProcMod's group,</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// and read control values off the envbus</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>server.sendMsg(<span class="s3">\s_new</span>, <span class="s3">\singrain</span>, server.nextNodeID, 0, group,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">\freq</span>, high.rrand(low), <span class="s3">\amp</span>, 1, <span class="s3">\dur</span>, winsize,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">\outbus</span>, routebus);</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>(winsize / overlaps).wait;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>})</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span>};</p>
<p class="p7"><br></p>
<p class="p6">// create new instances of ProcMod... store it to the variables 'b' and 'c'</p>
<p class="p5">b = a.value(0.2, <span class="s2">Env</span>([0, 1, 0], [1, 1], <span class="s3">\sin</span>, 1), 2000, 1000, 0.1, 4);</p>
<p class="p5">c = a.value(0.3, <span class="s2">Env</span>([0, 1, 0], [10, 0.1], [5, -10], 1), 440, 880, 0.4, 2);</p>
<p class="p7"><br></p>
<p class="p5">b.play; c.play;</p>
<p class="p7"><br></p>
<p class="p5">b.release;<span class="Apple-converted-space"> </span></p>
<p class="p5">c.release;</p>
<p class="p7"><br></p>
<p class="p3"><b>Re-triggerable ProcModRs</b></p>
<p class="p2"><br></p>
<p class="p3">ProcModRs are meant for the most part, to be played and released. However, if the function slot is passed a Function object, they can be re-triggered after they have been released. If the Function returns a Task or Routine, the ProcMod will function as though a Task or Routine were placed in the function slot (it will be started and released in the same way). Re-triggered events will be assigned a new group and envbus, so these are made available to the Function through arguments. If an OSCresponderNode or releaseFunc are needed for each re-triggered event, they should be assigned inside the Function:</p>
<p class="p2"><br></p>
<p class="p5"><span class="s5">SynthDef</span>(<span class="s6">\trig</span>, {<span class="s5">arg</span> id, val;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s5">SendTrig</span>.kr(<span class="s5">Impulse</span>.kr(10), id, val);</p>
<p class="p5"><span class="Apple-tab-span">	</span>}).load(s);</p>
<p class="p7"><span class="Apple-tab-span">	</span></p>
<p class="p5"><span class="s5">SynthDef</span>(<span class="s6">\singrain</span>, {<span class="s5">arg</span> freq, amp, dur, outbus;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s5">OffsetOut</span>.ar(outbus,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">Pan2</span>.ar(</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">SinOsc</span>.ar(freq, 0, amp) *<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">EnvGen</span>.kr(<span class="s5">Env</span>.sine(dur, amp), doneAction: 2),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>-1.0.rrand(1.0)</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p9"><span class="s4"><span class="Apple-tab-span">	</span>) </span>// read off the overall env control of the ProcMod</p>
<p class="p5">}).load(s);</p>
<p class="p7"><br></p>
<p class="p5">i = 0;</p>
<p class="p5">s.boot;</p>
<p class="p5">a = <span class="s5">ProcModR</span>.new(<span class="s5">Env</span>([0, 1, 0], [1, 3], <span class="s6">\sin</span>, 1), 1, 2, 0, server: s);</p>
<p class="p9">// use a function. This one returns the Task. group and envbus are passed in as args</p>
<p class="p5">a.function_({<span class="s5">arg</span> group, routebus, server;</p>
<p class="p5"><span class="Apple-tab-span">	</span>a.responder_(</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">OSCresponderNode</span>(a.server.addr, <span class="s6">'/tr'</span>, {<span class="s5">arg</span> time, resp, msg;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>(msg[2] == group).if({msg[3].postln})</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>})</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>);</p>
<p class="p10"><span class="s4"><span class="Apple-tab-span">	</span></span>Task<span class="s4">({</span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>s.sendMsg(<span class="s6">\s_new</span>, <span class="s6">\trig</span>, a.server.nextNodeID, 0, group, <span class="s6">\id</span>, group,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s6">\val</span>, i);</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>i = i + 1;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">inf</span>.do({</p>
<p class="p9"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// start a new synth... run it inside this ProcMod's group,</p>
<p class="p9"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// and read control values off the envbus</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>server.sendMsg(<span class="s6">\s_new</span>, <span class="s6">\singrain</span>, server.nextNodeID, 0,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>group, <span class="s6">\freq</span>, 440.rrand(880) * i, <span class="s6">\amp</span>, 0.1, <span class="s6">\dur</span>, 5,<span class="Apple-converted-space"> </span></p>
<p class="p11"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>\outbus, routebus<span class="s4">);</span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>0.05.wait;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span>});</p>
<p class="p7"><br></p>
<p class="p9"><span class="s4">a.play; </span>// play the ProcModR</p>
<p class="p9">// release the current event, and start a new one immediately. These will overlap.</p>
<p class="p9"><span class="s4">a.release; a.play; </span>// watch the posted values from the OSCresponderNode</p>
<p class="p5">a.release;</p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p3"><b>Recording the output of ProcModRs</b></p>
<p class="p2"><br></p>
<p class="p3">ProcModRs can record their output (anything that is sent to its private routebus) out to a file with the recordPM method. You just supply a basepath, and other timestamp info is added to it:</p>
<p class="p2"><br></p>
<p class="p5">a = {<span class="s2">arg</span> amp, env, high, low, winsize, overlaps, path;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> proc;</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span></span>// defaults to Server.default if no Server is supplied</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc = <span class="s2">ProcModR</span>.new(env, amp, 2, 0);</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc.recordPM(path);</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc.function_({<span class="s2">arg</span> group, routebus, server;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">Task</span>({</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">inf</span>.do({</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// start a new synth... run it inside this ProcMod's group,</p>
<p class="p6"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// and read control values off the envbus</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>server.sendMsg(<span class="s3">\s_new</span>, <span class="s3">\singrain</span>, server.nextNodeID, 0, group,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">\freq</span>, high.rrand(low), <span class="s3">\amp</span>, 1, <span class="s3">\dur</span>, winsize,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">\outbus</span>, routebus);</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>(winsize / overlaps).wait;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>})</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span>};</p>
<p class="p7"><br></p>
<p class="p6">// create new instances of ProcMod... store it to the variables 'b' and 'c'</p>
<p class="p5">b = a.value(0.2, <span class="s2">Env</span>([0, 1, 0], [1, 1], <span class="s3">\sin</span>, 1), 2000, 1000, 0.1, 4,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span>"~/Desktop/test1".standardizePath); // a base path, other time stamp info is added</p>
<p class="p5">c = a.value(0.3, <span class="s2">Env</span>([0, 1, 0], [10, 0.1], [5, -10], 1), 440, 880, 0.4, 2,</p>
<p class="p5"><span class="Apple-tab-span">	</span>"~/Desktop/test2".standardizePath);</p>
<p class="p7"><br></p>
<p class="p5">b.play; c.play;</p>
<p class="p7"><br></p>
<p class="p5">b.release;<span class="Apple-converted-space"> </span></p>
<p class="p5">c.release;</p>
<p class="p7"><br></p>
<p class="p12"><b>ProcModR and ProcEvents</b></p>
<p class="p13"><br></p>
<p class="p3">ProcModRs is interchangable with ProcMod. The main difference is you can give the .record method to ProcEvents, with a path, and it will use that base path to record every ProcModR out to it's own, timestamped file.</p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p5">(</p>
<p class="p5">a = {<span class="s7">arg</span> id, amp, env, high, low, winsize, overlaps;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s7">var</span> proc;</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc = <span class="s7">ProcModR</span>.new(env, amp, 2, 0, id: id);</p>
<p class="p5"><span class="Apple-tab-span">	</span>proc.function_({<span class="s7">arg</span> group, routebus, server;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">Task</span>({</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">inf</span>.do({</p>
<p class="p14"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// start a new synth... run it inside this ProcMod's group,</p>
<p class="p14"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>// and read control values off the envbus</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>server.sendMsg(<span class="s8">\s_new</span>, <span class="s8">\singrain</span>, server.nextNodeID, 0, group,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s8">\freq</span>, high.rrand(low), <span class="s8">\amp</span>, 1, <span class="s8">\dur</span>, winsize,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s8">\outbus</span>, routebus);</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>(winsize / overlaps).wait;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>})</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>});</p>
<p class="p5"><span class="Apple-tab-span">	</span>};</p>
<p class="p7"><br></p>
<p class="p5">e = <span class="s7">ProcEvents</span>.new([</p>
<p class="p5"><span class="s9">/* 0 */</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[a.value(<span class="s8">\ev1</span>, 0.1, <span class="s7">Env</span>([0, 1, 0], [2, 10], <span class="s8">\sin</span>, 1), 440, 880, 0.3, 8),</p>
<p class="p14"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><span class="s7">nil</span><span class="s4">], </span>// create \ev1, release nothing</p>
<p class="p5"><span class="s9">/* 1 */</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[a.value(<span class="s8">\ev2</span>, 0.1, <span class="s7">Env</span>([0, 1, 0], [1, 10], <span class="s8">\sin</span>, 1), 2200, 4400, 0.2, 8),</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">nil</span>],</p>
<p class="p5"><span class="s9">/* 2 */</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[a.value(<span class="s8">\ev3</span>, 0.1, <span class="s7">Env</span>([0, 1, 0.5, 2, 0], [1, 1, 1, 1], <span class="s8">\sin</span>, 1), 100,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>10000, 1, 4),</p>
<p class="p14"><span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[</span><span class="s8">\ev1</span><span class="s4">, </span><span class="s8">\ev2</span><span class="s4">]], </span>// release ev1 and ev2</p>
<p class="p14">/* 3 */<span class="s4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[</span><span class="s7">nil</span><span class="s4">, </span><span class="s8">\ev3</span><span class="s4">]</span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>], 0.dbamp, id: <span class="s10">"test"</span>);</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></p>
<p class="p5">e.record("~/Desktop/test".standardizePath, true, 'aiff', 'float');</p>
<p class="p5">)</p>
<p class="p7"><br></p>
<p class="p5">e.perfGUI;</p>
</body>
</html>
